
user/_btreetest:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <itoa>:
#include "kernel/fcntl.h"
#include "kernel/fs.h"
#include "kernel/btree.h"

void
itoa(int num, char* str) {
   0:	1141                	addi	sp,sp,-16
   2:	e422                	sd	s0,8(sp)
   4:	0800                	addi	s0,sp,16
    int i = 0;
    int isNegative = 0;

    // 处理负数
    if (num < 0) {
   6:	00054a63          	bltz	a0,1a <itoa+0x1a>
        isNegative = 1;
        num = -num;
    }

    // 处理0的特殊情况
    if (num == 0) {
   a:	e159                	bnez	a0,90 <itoa+0x90>
        str[i++] = '0';
   c:	03000793          	li	a5,48
  10:	00f58023          	sb	a5,0(a1)
        str[i] = '\0';
  14:	000580a3          	sb	zero,1(a1)
        return;
  18:	a88d                	j	8a <itoa+0x8a>
        num = -num;
  1a:	40a0053b          	negw	a0,a0
        isNegative = 1;
  1e:	4305                	li	t1,1
    }

    // 计算数字的位数
    while (num != 0) {
  20:	86ae                	mv	a3,a1
        isNegative = 1;
  22:	862e                	mv	a2,a1
    int i = 0;
  24:	4701                	li	a4,0
        int rem = num % 10;
  26:	4829                	li	a6,10
        str[i++] = rem + '0';  // 将数字转换为字符
  28:	88ba                	mv	a7,a4
  2a:	2705                	addiw	a4,a4,1
        int rem = num % 10;
  2c:	030567bb          	remw	a5,a0,a6
        str[i++] = rem + '0';  // 将数字转换为字符
  30:	0307879b          	addiw	a5,a5,48
  34:	00f60023          	sb	a5,0(a2)
        num = num / 10;
  38:	0305453b          	divw	a0,a0,a6
    while (num != 0) {
  3c:	0605                	addi	a2,a2,1
  3e:	f56d                	bnez	a0,28 <itoa+0x28>
    }

    // 如果是负数，添加负号
    if (isNegative) {
  40:	00030963          	beqz	t1,52 <itoa+0x52>
        str[i++] = '-';
  44:	972e                	add	a4,a4,a1
  46:	02d00793          	li	a5,45
  4a:	00f70023          	sb	a5,0(a4)
  4e:	0028871b          	addiw	a4,a7,2
    }

    str[i] = '\0';  // 添加字符串结束符
  52:	00e587b3          	add	a5,a1,a4
  56:	00078023          	sb	zero,0(a5)

    // 反转字符串
    int start = 0;
    int end = i - 1;
  5a:	fff7079b          	addiw	a5,a4,-1
    while (start < end) {
  5e:	02f05663          	blez	a5,8a <itoa+0x8a>
  62:	95be                	add	a1,a1,a5
        char temp = str[start];
  64:	0006c783          	lbu	a5,0(a3)
        str[start] = str[end];
  68:	0005c603          	lbu	a2,0(a1)
  6c:	00c68023          	sb	a2,0(a3)
        str[end] = temp;
  70:	00f58023          	sb	a5,0(a1)
        start++;
  74:	0015079b          	addiw	a5,a0,1
  78:	0007851b          	sext.w	a0,a5
    while (start < end) {
  7c:	0685                	addi	a3,a3,1
  7e:	15fd                	addi	a1,a1,-1
  80:	40f707bb          	subw	a5,a4,a5
  84:	37fd                	addiw	a5,a5,-1
  86:	fcf54fe3          	blt	a0,a5,64 <itoa+0x64>
        end--;
    }
}
  8a:	6422                	ld	s0,8(sp)
  8c:	0141                	addi	sp,sp,16
  8e:	8082                	ret
    int isNegative = 0;
  90:	4301                	li	t1,0
  92:	b779                	j	20 <itoa+0x20>

0000000000000094 <printbtn>:

void
printbtn(int fd, struct btreenode *btn){
  94:	d5010113          	addi	sp,sp,-688
  98:	2a113423          	sd	ra,680(sp)
  9c:	2a813023          	sd	s0,672(sp)
  a0:	28913c23          	sd	s1,664(sp)
  a4:	29213823          	sd	s2,656(sp)
  a8:	29313423          	sd	s3,648(sp)
  ac:	29413023          	sd	s4,640(sp)
  b0:	27513c23          	sd	s5,632(sp)
  b4:	1d00                	addi	s0,sp,688
  b6:	89aa                	mv	s3,a0
  b8:	892e                	mv	s2,a1
  printf("%d block btreenode start\n", btn->block);
  ba:	2685a583          	lw	a1,616(a1)
  be:	00001517          	auipc	a0,0x1
  c2:	c8a50513          	addi	a0,a0,-886 # d48 <malloc+0xe6>
  c6:	00001097          	auipc	ra,0x1
  ca:	ae4080e7          	jalr	-1308(ra) # baa <printf>
  for(int i = 0; i < btn->numkeys; i++){
  ce:	00492783          	lw	a5,4(s2)
  d2:	c79d                	beqz	a5,100 <printbtn+0x6c>
  d4:	00e90493          	addi	s1,s2,14
  d8:	4a01                	li	s4,0
    printf("%s ", btn->keys[i].name);
  da:	00001a97          	auipc	s5,0x1
  de:	c8ea8a93          	addi	s5,s5,-882 # d68 <malloc+0x106>
  e2:	85a6                	mv	a1,s1
  e4:	8556                	mv	a0,s5
  e6:	00001097          	auipc	ra,0x1
  ea:	ac4080e7          	jalr	-1340(ra) # baa <printf>
  for(int i = 0; i < btn->numkeys; i++){
  ee:	001a079b          	addiw	a5,s4,1
  f2:	00078a1b          	sext.w	s4,a5
  f6:	04c1                	addi	s1,s1,16
  f8:	00492703          	lw	a4,4(s2)
  fc:	feea63e3          	bltu	s4,a4,e2 <printbtn+0x4e>
  }
  printf("\n%d block btreenode over\n", btn->block);
 100:	26892583          	lw	a1,616(s2)
 104:	00001517          	auipc	a0,0x1
 108:	c6c50513          	addi	a0,a0,-916 # d70 <malloc+0x10e>
 10c:	00001097          	auipc	ra,0x1
 110:	a9e080e7          	jalr	-1378(ra) # baa <printf>
  for(int i = 0; i < btn->childnum; i++){
 114:	00892783          	lw	a5,8(s2)
 118:	cf9d                	beqz	a5,156 <printbtn+0xc2>
 11a:	1ec90493          	addi	s1,s2,492
 11e:	4a01                	li	s4,0
    if(btn->children[i] == 0){
 120:	4094                	lw	a3,0(s1)
 122:	cab9                	beqz	a3,178 <printbtn+0xe4>
      printf("btree readdir failed\n");
      close(fd);
      exit(1);
    }
    struct btreenode newbtn;
    rbtn(fd, &newbtn, sizeof(struct btreenode), btn->children[i]);
 124:	26c00613          	li	a2,620
 128:	d5040593          	addi	a1,s0,-688
 12c:	854e                	mv	a0,s3
 12e:	00000097          	auipc	ra,0x0
 132:	792080e7          	jalr	1938(ra) # 8c0 <rbtn>
    printbtn(fd, &newbtn);
 136:	d5040593          	addi	a1,s0,-688
 13a:	854e                	mv	a0,s3
 13c:	00000097          	auipc	ra,0x0
 140:	f58080e7          	jalr	-168(ra) # 94 <printbtn>
  for(int i = 0; i < btn->childnum; i++){
 144:	001a079b          	addiw	a5,s4,1
 148:	00078a1b          	sext.w	s4,a5
 14c:	0491                	addi	s1,s1,4
 14e:	00892703          	lw	a4,8(s2)
 152:	fcea67e3          	bltu	s4,a4,120 <printbtn+0x8c>
  }
}
 156:	2a813083          	ld	ra,680(sp)
 15a:	2a013403          	ld	s0,672(sp)
 15e:	29813483          	ld	s1,664(sp)
 162:	29013903          	ld	s2,656(sp)
 166:	28813983          	ld	s3,648(sp)
 16a:	28013a03          	ld	s4,640(sp)
 16e:	27813a83          	ld	s5,632(sp)
 172:	2b010113          	addi	sp,sp,688
 176:	8082                	ret
      printf("btree readdir failed\n");
 178:	00001517          	auipc	a0,0x1
 17c:	c1850513          	addi	a0,a0,-1000 # d90 <malloc+0x12e>
 180:	00001097          	auipc	ra,0x1
 184:	a2a080e7          	jalr	-1494(ra) # baa <printf>
      close(fd);
 188:	854e                	mv	a0,s3
 18a:	00000097          	auipc	ra,0x0
 18e:	6be080e7          	jalr	1726(ra) # 848 <close>
      exit(1);
 192:	4505                	li	a0,1
 194:	00000097          	auipc	ra,0x0
 198:	68c080e7          	jalr	1676(ra) # 820 <exit>

000000000000019c <dirtest>:

void dirtest(){
 19c:	1141                	addi	sp,sp,-16
 19e:	e406                	sd	ra,8(sp)
 1a0:	e022                	sd	s0,0(sp)
 1a2:	0800                	addi	s0,sp,16
  if(mkdir("dir0") < 0){
 1a4:	00001517          	auipc	a0,0x1
 1a8:	c0450513          	addi	a0,a0,-1020 # da8 <malloc+0x146>
 1ac:	00000097          	auipc	ra,0x0
 1b0:	6dc080e7          	jalr	1756(ra) # 888 <mkdir>
 1b4:	02054a63          	bltz	a0,1e8 <dirtest+0x4c>
    printf("mkdir failed\n");
    exit(1);
  }

  if(chdir("dir0") < 0){
 1b8:	00001517          	auipc	a0,0x1
 1bc:	bf050513          	addi	a0,a0,-1040 # da8 <malloc+0x146>
 1c0:	00000097          	auipc	ra,0x0
 1c4:	6d0080e7          	jalr	1744(ra) # 890 <chdir>
 1c8:	02054d63          	bltz	a0,202 <dirtest+0x66>
    printf("chdir dir0 failed\n");
    exit(1);
  }

  if(chdir("..") < 0){
 1cc:	00001517          	auipc	a0,0x1
 1d0:	c0c50513          	addi	a0,a0,-1012 # dd8 <malloc+0x176>
 1d4:	00000097          	auipc	ra,0x0
 1d8:	6bc080e7          	jalr	1724(ra) # 890 <chdir>
 1dc:	04054063          	bltz	a0,21c <dirtest+0x80>
    printf("chdir .. failed\n");
    exit(1);
  }
}
 1e0:	60a2                	ld	ra,8(sp)
 1e2:	6402                	ld	s0,0(sp)
 1e4:	0141                	addi	sp,sp,16
 1e6:	8082                	ret
    printf("mkdir failed\n");
 1e8:	00001517          	auipc	a0,0x1
 1ec:	bc850513          	addi	a0,a0,-1080 # db0 <malloc+0x14e>
 1f0:	00001097          	auipc	ra,0x1
 1f4:	9ba080e7          	jalr	-1606(ra) # baa <printf>
    exit(1);
 1f8:	4505                	li	a0,1
 1fa:	00000097          	auipc	ra,0x0
 1fe:	626080e7          	jalr	1574(ra) # 820 <exit>
    printf("chdir dir0 failed\n");
 202:	00001517          	auipc	a0,0x1
 206:	bbe50513          	addi	a0,a0,-1090 # dc0 <malloc+0x15e>
 20a:	00001097          	auipc	ra,0x1
 20e:	9a0080e7          	jalr	-1632(ra) # baa <printf>
    exit(1);
 212:	4505                	li	a0,1
 214:	00000097          	auipc	ra,0x0
 218:	60c080e7          	jalr	1548(ra) # 820 <exit>
    printf("chdir .. failed\n");
 21c:	00001517          	auipc	a0,0x1
 220:	bc450513          	addi	a0,a0,-1084 # de0 <malloc+0x17e>
 224:	00001097          	auipc	ra,0x1
 228:	986080e7          	jalr	-1658(ra) # baa <printf>
    exit(1);
 22c:	4505                	li	a0,1
 22e:	00000097          	auipc	ra,0x0
 232:	5f2080e7          	jalr	1522(ra) # 820 <exit>

0000000000000236 <dirfile>:

void dirfile(){
 236:	1101                	addi	sp,sp,-32
 238:	ec06                	sd	ra,24(sp)
 23a:	e822                	sd	s0,16(sp)
 23c:	e426                	sd	s1,8(sp)
 23e:	1000                	addi	s0,sp,32
  int fd;
  fd = open("dirfile", O_CREATE);
 240:	20000593          	li	a1,512
 244:	00001517          	auipc	a0,0x1
 248:	bb450513          	addi	a0,a0,-1100 # df8 <malloc+0x196>
 24c:	00000097          	auipc	ra,0x0
 250:	614080e7          	jalr	1556(ra) # 860 <open>
  if(fd < 0){
 254:	0a054963          	bltz	a0,306 <dirfile+0xd0>
    printf("create dirfile failed\n");
    exit(1);
  }
  close(fd);
 258:	00000097          	auipc	ra,0x0
 25c:	5f0080e7          	jalr	1520(ra) # 848 <close>
  if(chdir("dirfile") == 0){
 260:	00001517          	auipc	a0,0x1
 264:	b9850513          	addi	a0,a0,-1128 # df8 <malloc+0x196>
 268:	00000097          	auipc	ra,0x0
 26c:	628080e7          	jalr	1576(ra) # 890 <chdir>
 270:	c945                	beqz	a0,320 <dirfile+0xea>
    printf("chdir dirfile succeeded!\n");
    exit(1);
  }
  fd = open("dirfile/xx", 0);
 272:	4581                	li	a1,0
 274:	00001517          	auipc	a0,0x1
 278:	bc450513          	addi	a0,a0,-1084 # e38 <malloc+0x1d6>
 27c:	00000097          	auipc	ra,0x0
 280:	5e4080e7          	jalr	1508(ra) # 860 <open>
  if(fd >= 0){
 284:	0a055b63          	bgez	a0,33a <dirfile+0x104>
    printf("create dirfile/xx succeeded!\n");
    exit(1);
  }
  fd = open("dirfile/xx", O_CREATE);
 288:	20000593          	li	a1,512
 28c:	00001517          	auipc	a0,0x1
 290:	bac50513          	addi	a0,a0,-1108 # e38 <malloc+0x1d6>
 294:	00000097          	auipc	ra,0x0
 298:	5cc080e7          	jalr	1484(ra) # 860 <open>
  if(fd >= 0){
 29c:	0a055c63          	bgez	a0,354 <dirfile+0x11e>
    printf("create dirfile/xx succeeded!\n");
    exit(1);
  }
  if(mkdir("dirfile/xx") == 0){
 2a0:	00001517          	auipc	a0,0x1
 2a4:	b9850513          	addi	a0,a0,-1128 # e38 <malloc+0x1d6>
 2a8:	00000097          	auipc	ra,0x0
 2ac:	5e0080e7          	jalr	1504(ra) # 888 <mkdir>
 2b0:	cd5d                	beqz	a0,36e <dirfile+0x138>
    printf("mkdir dirfile/xx succeeded!\n");
    exit(1);
  }

  fd = open(".", O_RDWR);
 2b2:	4589                	li	a1,2
 2b4:	00001517          	auipc	a0,0x1
 2b8:	bd450513          	addi	a0,a0,-1068 # e88 <malloc+0x226>
 2bc:	00000097          	auipc	ra,0x0
 2c0:	5a4080e7          	jalr	1444(ra) # 860 <open>
  if(fd >= 0){
 2c4:	0c055263          	bgez	a0,388 <dirfile+0x152>
    printf("open . for writing succeeded!\n");
    exit(1);
  }
  fd = open(".", 0);
 2c8:	4581                	li	a1,0
 2ca:	00001517          	auipc	a0,0x1
 2ce:	bbe50513          	addi	a0,a0,-1090 # e88 <malloc+0x226>
 2d2:	00000097          	auipc	ra,0x0
 2d6:	58e080e7          	jalr	1422(ra) # 860 <open>
 2da:	84aa                	mv	s1,a0
  if(write(fd, "x", 1) > 0){
 2dc:	4605                	li	a2,1
 2de:	00001597          	auipc	a1,0x1
 2e2:	bd258593          	addi	a1,a1,-1070 # eb0 <malloc+0x24e>
 2e6:	00000097          	auipc	ra,0x0
 2ea:	55a080e7          	jalr	1370(ra) # 840 <write>
 2ee:	0aa04a63          	bgtz	a0,3a2 <dirfile+0x16c>
    printf("write . succeeded!\n");
    exit(1);
  }
  close(fd);
 2f2:	8526                	mv	a0,s1
 2f4:	00000097          	auipc	ra,0x0
 2f8:	554080e7          	jalr	1364(ra) # 848 <close>
}
 2fc:	60e2                	ld	ra,24(sp)
 2fe:	6442                	ld	s0,16(sp)
 300:	64a2                	ld	s1,8(sp)
 302:	6105                	addi	sp,sp,32
 304:	8082                	ret
    printf("create dirfile failed\n");
 306:	00001517          	auipc	a0,0x1
 30a:	afa50513          	addi	a0,a0,-1286 # e00 <malloc+0x19e>
 30e:	00001097          	auipc	ra,0x1
 312:	89c080e7          	jalr	-1892(ra) # baa <printf>
    exit(1);
 316:	4505                	li	a0,1
 318:	00000097          	auipc	ra,0x0
 31c:	508080e7          	jalr	1288(ra) # 820 <exit>
    printf("chdir dirfile succeeded!\n");
 320:	00001517          	auipc	a0,0x1
 324:	af850513          	addi	a0,a0,-1288 # e18 <malloc+0x1b6>
 328:	00001097          	auipc	ra,0x1
 32c:	882080e7          	jalr	-1918(ra) # baa <printf>
    exit(1);
 330:	4505                	li	a0,1
 332:	00000097          	auipc	ra,0x0
 336:	4ee080e7          	jalr	1262(ra) # 820 <exit>
    printf("create dirfile/xx succeeded!\n");
 33a:	00001517          	auipc	a0,0x1
 33e:	b0e50513          	addi	a0,a0,-1266 # e48 <malloc+0x1e6>
 342:	00001097          	auipc	ra,0x1
 346:	868080e7          	jalr	-1944(ra) # baa <printf>
    exit(1);
 34a:	4505                	li	a0,1
 34c:	00000097          	auipc	ra,0x0
 350:	4d4080e7          	jalr	1236(ra) # 820 <exit>
    printf("create dirfile/xx succeeded!\n");
 354:	00001517          	auipc	a0,0x1
 358:	af450513          	addi	a0,a0,-1292 # e48 <malloc+0x1e6>
 35c:	00001097          	auipc	ra,0x1
 360:	84e080e7          	jalr	-1970(ra) # baa <printf>
    exit(1);
 364:	4505                	li	a0,1
 366:	00000097          	auipc	ra,0x0
 36a:	4ba080e7          	jalr	1210(ra) # 820 <exit>
    printf("mkdir dirfile/xx succeeded!\n");
 36e:	00001517          	auipc	a0,0x1
 372:	afa50513          	addi	a0,a0,-1286 # e68 <malloc+0x206>
 376:	00001097          	auipc	ra,0x1
 37a:	834080e7          	jalr	-1996(ra) # baa <printf>
    exit(1);
 37e:	4505                	li	a0,1
 380:	00000097          	auipc	ra,0x0
 384:	4a0080e7          	jalr	1184(ra) # 820 <exit>
    printf("open . for writing succeeded!\n");
 388:	00001517          	auipc	a0,0x1
 38c:	b0850513          	addi	a0,a0,-1272 # e90 <malloc+0x22e>
 390:	00001097          	auipc	ra,0x1
 394:	81a080e7          	jalr	-2022(ra) # baa <printf>
    exit(1);
 398:	4505                	li	a0,1
 39a:	00000097          	auipc	ra,0x0
 39e:	486080e7          	jalr	1158(ra) # 820 <exit>
    printf("write . succeeded!\n");
 3a2:	00001517          	auipc	a0,0x1
 3a6:	b1650513          	addi	a0,a0,-1258 # eb8 <malloc+0x256>
 3aa:	00001097          	auipc	ra,0x1
 3ae:	800080e7          	jalr	-2048(ra) # baa <printf>
    exit(1);
 3b2:	4505                	li	a0,1
 3b4:	00000097          	auipc	ra,0x0
 3b8:	46c080e7          	jalr	1132(ra) # 820 <exit>

00000000000003bc <readdir>:

void readdir(){
 3bc:	b6010113          	addi	sp,sp,-1184
 3c0:	48113c23          	sd	ra,1176(sp)
 3c4:	48813823          	sd	s0,1168(sp)
 3c8:	48913423          	sd	s1,1160(sp)
 3cc:	49213023          	sd	s2,1152(sp)
 3d0:	4a010413          	addi	s0,sp,1184
  // 创建0-29目录
  for(int i = 0; i < 30; i++){
 3d4:	4481                	li	s1,0
 3d6:	4979                	li	s2,30
    char dirname[DIRSIZ]; // 确保这个数组足够大以存放字符串
    itoa(i, dirname); // 将整数i格式化为字符串"dirX"
 3d8:	b6040593          	addi	a1,s0,-1184
 3dc:	8526                	mv	a0,s1
 3de:	00000097          	auipc	ra,0x0
 3e2:	c22080e7          	jalr	-990(ra) # 0 <itoa>
    if(mkdir(dirname) < 0){
 3e6:	b6040513          	addi	a0,s0,-1184
 3ea:	00000097          	auipc	ra,0x0
 3ee:	49e080e7          	jalr	1182(ra) # 888 <mkdir>
 3f2:	0a054e63          	bltz	a0,4ae <readdir+0xf2>
  for(int i = 0; i < 30; i++){
 3f6:	2485                	addiw	s1,s1,1
 3f8:	ff2490e3          	bne	s1,s2,3d8 <readdir+0x1c>
  char buf[512], *p;
  char *path = ".";
  struct btreenode btn;
  int fd;

  if((fd = open(path, 0)) < 0){
 3fc:	4581                	li	a1,0
 3fe:	00001517          	auipc	a0,0x1
 402:	a8a50513          	addi	a0,a0,-1398 # e88 <malloc+0x226>
 406:	00000097          	auipc	ra,0x0
 40a:	45a080e7          	jalr	1114(ra) # 860 <open>
 40e:	84aa                	mv	s1,a0
 410:	0a054c63          	bltz	a0,4c8 <readdir+0x10c>
    printf("open . for writing failed!\n");
    exit(1);
  }

  if(strlen(path) + 1 + DIRSIZ + 1 > sizeof buf){
 414:	00001517          	auipc	a0,0x1
 418:	a7450513          	addi	a0,a0,-1420 # e88 <malloc+0x226>
 41c:	00000097          	auipc	ra,0x0
 420:	1e0080e7          	jalr	480(ra) # 5fc <strlen>
 424:	2541                	addiw	a0,a0,16
 426:	20000793          	li	a5,512
 42a:	0aa7ec63          	bltu	a5,a0,4e2 <readdir+0x126>
    printf("path too long\n");
    close(fd);
    exit(1);
  }

  strcpy(buf, path);
 42e:	00001597          	auipc	a1,0x1
 432:	a5a58593          	addi	a1,a1,-1446 # e88 <malloc+0x226>
 436:	de040513          	addi	a0,s0,-544
 43a:	00000097          	auipc	ra,0x0
 43e:	17a080e7          	jalr	378(ra) # 5b4 <strcpy>
  p = buf+strlen(buf);
 442:	de040513          	addi	a0,s0,-544
 446:	00000097          	auipc	ra,0x0
 44a:	1b6080e7          	jalr	438(ra) # 5fc <strlen>
 44e:	02051793          	slli	a5,a0,0x20
 452:	9381                	srli	a5,a5,0x20
  *p++ = '/';
 454:	1781                	addi	a5,a5,-32
 456:	97a2                	add	a5,a5,s0
 458:	02f00713          	li	a4,47
 45c:	e0e78023          	sb	a4,-512(a5)

  if(read(fd, &btn, sizeof(struct btreenode)) == sizeof(struct btreenode)){
 460:	26c00613          	li	a2,620
 464:	b7040593          	addi	a1,s0,-1168
 468:	8526                	mv	a0,s1
 46a:	00000097          	auipc	ra,0x0
 46e:	3ce080e7          	jalr	974(ra) # 838 <read>
 472:	26c00793          	li	a5,620
 476:	00f51c63          	bne	a0,a5,48e <readdir+0xd2>
    if(btn.block == 0){
 47a:	dd842783          	lw	a5,-552(s0)
 47e:	c7c1                	beqz	a5,506 <readdir+0x14a>
      printf("btree readdir failed\n");
      close(fd);
      exit(1);
    }
    printbtn(fd, &btn);
 480:	b7040593          	addi	a1,s0,-1168
 484:	8526                	mv	a0,s1
 486:	00000097          	auipc	ra,0x0
 48a:	c0e080e7          	jalr	-1010(ra) # 94 <printbtn>
  }
  close(fd);
 48e:	8526                	mv	a0,s1
 490:	00000097          	auipc	ra,0x0
 494:	3b8080e7          	jalr	952(ra) # 848 <close>
}
 498:	49813083          	ld	ra,1176(sp)
 49c:	49013403          	ld	s0,1168(sp)
 4a0:	48813483          	ld	s1,1160(sp)
 4a4:	48013903          	ld	s2,1152(sp)
 4a8:	4a010113          	addi	sp,sp,1184
 4ac:	8082                	ret
      printf("mkdir failed\n");
 4ae:	00001517          	auipc	a0,0x1
 4b2:	90250513          	addi	a0,a0,-1790 # db0 <malloc+0x14e>
 4b6:	00000097          	auipc	ra,0x0
 4ba:	6f4080e7          	jalr	1780(ra) # baa <printf>
      exit(1);
 4be:	4505                	li	a0,1
 4c0:	00000097          	auipc	ra,0x0
 4c4:	360080e7          	jalr	864(ra) # 820 <exit>
    printf("open . for writing failed!\n");
 4c8:	00001517          	auipc	a0,0x1
 4cc:	a0850513          	addi	a0,a0,-1528 # ed0 <malloc+0x26e>
 4d0:	00000097          	auipc	ra,0x0
 4d4:	6da080e7          	jalr	1754(ra) # baa <printf>
    exit(1);
 4d8:	4505                	li	a0,1
 4da:	00000097          	auipc	ra,0x0
 4de:	346080e7          	jalr	838(ra) # 820 <exit>
    printf("path too long\n");
 4e2:	00001517          	auipc	a0,0x1
 4e6:	a0e50513          	addi	a0,a0,-1522 # ef0 <malloc+0x28e>
 4ea:	00000097          	auipc	ra,0x0
 4ee:	6c0080e7          	jalr	1728(ra) # baa <printf>
    close(fd);
 4f2:	8526                	mv	a0,s1
 4f4:	00000097          	auipc	ra,0x0
 4f8:	354080e7          	jalr	852(ra) # 848 <close>
    exit(1);
 4fc:	4505                	li	a0,1
 4fe:	00000097          	auipc	ra,0x0
 502:	322080e7          	jalr	802(ra) # 820 <exit>
      printf("btree readdir failed\n");
 506:	00001517          	auipc	a0,0x1
 50a:	88a50513          	addi	a0,a0,-1910 # d90 <malloc+0x12e>
 50e:	00000097          	auipc	ra,0x0
 512:	69c080e7          	jalr	1692(ra) # baa <printf>
      close(fd);
 516:	8526                	mv	a0,s1
 518:	00000097          	auipc	ra,0x0
 51c:	330080e7          	jalr	816(ra) # 848 <close>
      exit(1);
 520:	4505                	li	a0,1
 522:	00000097          	auipc	ra,0x0
 526:	2fe080e7          	jalr	766(ra) # 820 <exit>

000000000000052a <main>:

int
main()
{
 52a:	1141                	addi	sp,sp,-16
 52c:	e406                	sd	ra,8(sp)
 52e:	e022                	sd	s0,0(sp)
 530:	0800                	addi	s0,sp,16
  printf("test btree dirtest: "); 
 532:	00001517          	auipc	a0,0x1
 536:	9ce50513          	addi	a0,a0,-1586 # f00 <malloc+0x29e>
 53a:	00000097          	auipc	ra,0x0
 53e:	670080e7          	jalr	1648(ra) # baa <printf>
  dirtest();
 542:	00000097          	auipc	ra,0x0
 546:	c5a080e7          	jalr	-934(ra) # 19c <dirtest>
  printf("ok\n"); 
 54a:	00001517          	auipc	a0,0x1
 54e:	9ce50513          	addi	a0,a0,-1586 # f18 <malloc+0x2b6>
 552:	00000097          	auipc	ra,0x0
 556:	658080e7          	jalr	1624(ra) # baa <printf>
  printf("test btree dirfile: "); 
 55a:	00001517          	auipc	a0,0x1
 55e:	9c650513          	addi	a0,a0,-1594 # f20 <malloc+0x2be>
 562:	00000097          	auipc	ra,0x0
 566:	648080e7          	jalr	1608(ra) # baa <printf>
  dirfile();
 56a:	00000097          	auipc	ra,0x0
 56e:	ccc080e7          	jalr	-820(ra) # 236 <dirfile>
  printf("ok\n"); 
 572:	00001517          	auipc	a0,0x1
 576:	9a650513          	addi	a0,a0,-1626 # f18 <malloc+0x2b6>
 57a:	00000097          	auipc	ra,0x0
 57e:	630080e7          	jalr	1584(ra) # baa <printf>
  printf("test btree readdir: \n"); 
 582:	00001517          	auipc	a0,0x1
 586:	9b650513          	addi	a0,a0,-1610 # f38 <malloc+0x2d6>
 58a:	00000097          	auipc	ra,0x0
 58e:	620080e7          	jalr	1568(ra) # baa <printf>
  readdir();
 592:	00000097          	auipc	ra,0x0
 596:	e2a080e7          	jalr	-470(ra) # 3bc <readdir>
  printf("ok\n"); 
 59a:	00001517          	auipc	a0,0x1
 59e:	97e50513          	addi	a0,a0,-1666 # f18 <malloc+0x2b6>
 5a2:	00000097          	auipc	ra,0x0
 5a6:	608080e7          	jalr	1544(ra) # baa <printf>
  exit(0);
 5aa:	4501                	li	a0,0
 5ac:	00000097          	auipc	ra,0x0
 5b0:	274080e7          	jalr	628(ra) # 820 <exit>

00000000000005b4 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"

char*
strcpy(char *s, const char *t)
{
 5b4:	1141                	addi	sp,sp,-16
 5b6:	e422                	sd	s0,8(sp)
 5b8:	0800                	addi	s0,sp,16
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
 5ba:	87aa                	mv	a5,a0
 5bc:	0585                	addi	a1,a1,1
 5be:	0785                	addi	a5,a5,1
 5c0:	fff5c703          	lbu	a4,-1(a1)
 5c4:	fee78fa3          	sb	a4,-1(a5)
 5c8:	fb75                	bnez	a4,5bc <strcpy+0x8>
    ;
  return os;
}
 5ca:	6422                	ld	s0,8(sp)
 5cc:	0141                	addi	sp,sp,16
 5ce:	8082                	ret

00000000000005d0 <strcmp>:

int
strcmp(const char *p, const char *q)
{
 5d0:	1141                	addi	sp,sp,-16
 5d2:	e422                	sd	s0,8(sp)
 5d4:	0800                	addi	s0,sp,16
  while(*p && *p == *q)
 5d6:	00054783          	lbu	a5,0(a0)
 5da:	cb91                	beqz	a5,5ee <strcmp+0x1e>
 5dc:	0005c703          	lbu	a4,0(a1)
 5e0:	00f71763          	bne	a4,a5,5ee <strcmp+0x1e>
    p++, q++;
 5e4:	0505                	addi	a0,a0,1
 5e6:	0585                	addi	a1,a1,1
  while(*p && *p == *q)
 5e8:	00054783          	lbu	a5,0(a0)
 5ec:	fbe5                	bnez	a5,5dc <strcmp+0xc>
  return (uchar)*p - (uchar)*q;
 5ee:	0005c503          	lbu	a0,0(a1)
}
 5f2:	40a7853b          	subw	a0,a5,a0
 5f6:	6422                	ld	s0,8(sp)
 5f8:	0141                	addi	sp,sp,16
 5fa:	8082                	ret

00000000000005fc <strlen>:

uint
strlen(const char *s)
{
 5fc:	1141                	addi	sp,sp,-16
 5fe:	e422                	sd	s0,8(sp)
 600:	0800                	addi	s0,sp,16
  int n;

  for(n = 0; s[n]; n++)
 602:	00054783          	lbu	a5,0(a0)
 606:	cf91                	beqz	a5,622 <strlen+0x26>
 608:	0505                	addi	a0,a0,1
 60a:	87aa                	mv	a5,a0
 60c:	4685                	li	a3,1
 60e:	9e89                	subw	a3,a3,a0
 610:	00f6853b          	addw	a0,a3,a5
 614:	0785                	addi	a5,a5,1
 616:	fff7c703          	lbu	a4,-1(a5)
 61a:	fb7d                	bnez	a4,610 <strlen+0x14>
    ;
  return n;
}
 61c:	6422                	ld	s0,8(sp)
 61e:	0141                	addi	sp,sp,16
 620:	8082                	ret
  for(n = 0; s[n]; n++)
 622:	4501                	li	a0,0
 624:	bfe5                	j	61c <strlen+0x20>

0000000000000626 <memset>:

void*
memset(void *dst, int c, uint n)
{
 626:	1141                	addi	sp,sp,-16
 628:	e422                	sd	s0,8(sp)
 62a:	0800                	addi	s0,sp,16
  char *cdst = (char *) dst;
  int i;
  for(i = 0; i < n; i++){
 62c:	ca19                	beqz	a2,642 <memset+0x1c>
 62e:	87aa                	mv	a5,a0
 630:	1602                	slli	a2,a2,0x20
 632:	9201                	srli	a2,a2,0x20
 634:	00a60733          	add	a4,a2,a0
    cdst[i] = c;
 638:	00b78023          	sb	a1,0(a5)
  for(i = 0; i < n; i++){
 63c:	0785                	addi	a5,a5,1
 63e:	fee79de3          	bne	a5,a4,638 <memset+0x12>
  }
  return dst;
}
 642:	6422                	ld	s0,8(sp)
 644:	0141                	addi	sp,sp,16
 646:	8082                	ret

0000000000000648 <strchr>:

char*
strchr(const char *s, char c)
{
 648:	1141                	addi	sp,sp,-16
 64a:	e422                	sd	s0,8(sp)
 64c:	0800                	addi	s0,sp,16
  for(; *s; s++)
 64e:	00054783          	lbu	a5,0(a0)
 652:	cb99                	beqz	a5,668 <strchr+0x20>
    if(*s == c)
 654:	00f58763          	beq	a1,a5,662 <strchr+0x1a>
  for(; *s; s++)
 658:	0505                	addi	a0,a0,1
 65a:	00054783          	lbu	a5,0(a0)
 65e:	fbfd                	bnez	a5,654 <strchr+0xc>
      return (char*)s;
  return 0;
 660:	4501                	li	a0,0
}
 662:	6422                	ld	s0,8(sp)
 664:	0141                	addi	sp,sp,16
 666:	8082                	ret
  return 0;
 668:	4501                	li	a0,0
 66a:	bfe5                	j	662 <strchr+0x1a>

000000000000066c <gets>:

char*
gets(char *buf, int max)
{
 66c:	711d                	addi	sp,sp,-96
 66e:	ec86                	sd	ra,88(sp)
 670:	e8a2                	sd	s0,80(sp)
 672:	e4a6                	sd	s1,72(sp)
 674:	e0ca                	sd	s2,64(sp)
 676:	fc4e                	sd	s3,56(sp)
 678:	f852                	sd	s4,48(sp)
 67a:	f456                	sd	s5,40(sp)
 67c:	f05a                	sd	s6,32(sp)
 67e:	ec5e                	sd	s7,24(sp)
 680:	1080                	addi	s0,sp,96
 682:	8baa                	mv	s7,a0
 684:	8a2e                	mv	s4,a1
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
 686:	892a                	mv	s2,a0
 688:	4481                	li	s1,0
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
 68a:	4aa9                	li	s5,10
 68c:	4b35                	li	s6,13
  for(i=0; i+1 < max; ){
 68e:	89a6                	mv	s3,s1
 690:	2485                	addiw	s1,s1,1
 692:	0344d863          	bge	s1,s4,6c2 <gets+0x56>
    cc = read(0, &c, 1);
 696:	4605                	li	a2,1
 698:	faf40593          	addi	a1,s0,-81
 69c:	4501                	li	a0,0
 69e:	00000097          	auipc	ra,0x0
 6a2:	19a080e7          	jalr	410(ra) # 838 <read>
    if(cc < 1)
 6a6:	00a05e63          	blez	a0,6c2 <gets+0x56>
    buf[i++] = c;
 6aa:	faf44783          	lbu	a5,-81(s0)
 6ae:	00f90023          	sb	a5,0(s2)
    if(c == '\n' || c == '\r')
 6b2:	01578763          	beq	a5,s5,6c0 <gets+0x54>
 6b6:	0905                	addi	s2,s2,1
 6b8:	fd679be3          	bne	a5,s6,68e <gets+0x22>
  for(i=0; i+1 < max; ){
 6bc:	89a6                	mv	s3,s1
 6be:	a011                	j	6c2 <gets+0x56>
 6c0:	89a6                	mv	s3,s1
      break;
  }
  buf[i] = '\0';
 6c2:	99de                	add	s3,s3,s7
 6c4:	00098023          	sb	zero,0(s3)
  return buf;
}
 6c8:	855e                	mv	a0,s7
 6ca:	60e6                	ld	ra,88(sp)
 6cc:	6446                	ld	s0,80(sp)
 6ce:	64a6                	ld	s1,72(sp)
 6d0:	6906                	ld	s2,64(sp)
 6d2:	79e2                	ld	s3,56(sp)
 6d4:	7a42                	ld	s4,48(sp)
 6d6:	7aa2                	ld	s5,40(sp)
 6d8:	7b02                	ld	s6,32(sp)
 6da:	6be2                	ld	s7,24(sp)
 6dc:	6125                	addi	sp,sp,96
 6de:	8082                	ret

00000000000006e0 <stat>:

int
stat(const char *n, struct stat *st)
{
 6e0:	1101                	addi	sp,sp,-32
 6e2:	ec06                	sd	ra,24(sp)
 6e4:	e822                	sd	s0,16(sp)
 6e6:	e426                	sd	s1,8(sp)
 6e8:	e04a                	sd	s2,0(sp)
 6ea:	1000                	addi	s0,sp,32
 6ec:	892e                	mv	s2,a1
  int fd;
  int r;

  fd = open(n, O_RDONLY);
 6ee:	4581                	li	a1,0
 6f0:	00000097          	auipc	ra,0x0
 6f4:	170080e7          	jalr	368(ra) # 860 <open>
  if(fd < 0)
 6f8:	02054563          	bltz	a0,722 <stat+0x42>
 6fc:	84aa                	mv	s1,a0
    return -1;
  r = fstat(fd, st);
 6fe:	85ca                	mv	a1,s2
 700:	00000097          	auipc	ra,0x0
 704:	178080e7          	jalr	376(ra) # 878 <fstat>
 708:	892a                	mv	s2,a0
  close(fd);
 70a:	8526                	mv	a0,s1
 70c:	00000097          	auipc	ra,0x0
 710:	13c080e7          	jalr	316(ra) # 848 <close>
  return r;
}
 714:	854a                	mv	a0,s2
 716:	60e2                	ld	ra,24(sp)
 718:	6442                	ld	s0,16(sp)
 71a:	64a2                	ld	s1,8(sp)
 71c:	6902                	ld	s2,0(sp)
 71e:	6105                	addi	sp,sp,32
 720:	8082                	ret
    return -1;
 722:	597d                	li	s2,-1
 724:	bfc5                	j	714 <stat+0x34>

0000000000000726 <atoi>:

int
atoi(const char *s)
{
 726:	1141                	addi	sp,sp,-16
 728:	e422                	sd	s0,8(sp)
 72a:	0800                	addi	s0,sp,16
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
 72c:	00054683          	lbu	a3,0(a0)
 730:	fd06879b          	addiw	a5,a3,-48
 734:	0ff7f793          	zext.b	a5,a5
 738:	4625                	li	a2,9
 73a:	02f66863          	bltu	a2,a5,76a <atoi+0x44>
 73e:	872a                	mv	a4,a0
  n = 0;
 740:	4501                	li	a0,0
    n = n*10 + *s++ - '0';
 742:	0705                	addi	a4,a4,1
 744:	0025179b          	slliw	a5,a0,0x2
 748:	9fa9                	addw	a5,a5,a0
 74a:	0017979b          	slliw	a5,a5,0x1
 74e:	9fb5                	addw	a5,a5,a3
 750:	fd07851b          	addiw	a0,a5,-48
  while('0' <= *s && *s <= '9')
 754:	00074683          	lbu	a3,0(a4)
 758:	fd06879b          	addiw	a5,a3,-48
 75c:	0ff7f793          	zext.b	a5,a5
 760:	fef671e3          	bgeu	a2,a5,742 <atoi+0x1c>
  return n;
}
 764:	6422                	ld	s0,8(sp)
 766:	0141                	addi	sp,sp,16
 768:	8082                	ret
  n = 0;
 76a:	4501                	li	a0,0
 76c:	bfe5                	j	764 <atoi+0x3e>

000000000000076e <memmove>:

void*
memmove(void *vdst, const void *vsrc, int n)
{
 76e:	1141                	addi	sp,sp,-16
 770:	e422                	sd	s0,8(sp)
 772:	0800                	addi	s0,sp,16
  char *dst;
  const char *src;

  dst = vdst;
  src = vsrc;
  if (src > dst) {
 774:	02b57463          	bgeu	a0,a1,79c <memmove+0x2e>
    while(n-- > 0)
 778:	00c05f63          	blez	a2,796 <memmove+0x28>
 77c:	1602                	slli	a2,a2,0x20
 77e:	9201                	srli	a2,a2,0x20
 780:	00c507b3          	add	a5,a0,a2
  dst = vdst;
 784:	872a                	mv	a4,a0
      *dst++ = *src++;
 786:	0585                	addi	a1,a1,1
 788:	0705                	addi	a4,a4,1
 78a:	fff5c683          	lbu	a3,-1(a1)
 78e:	fed70fa3          	sb	a3,-1(a4)
    while(n-- > 0)
 792:	fee79ae3          	bne	a5,a4,786 <memmove+0x18>
    src += n;
    while(n-- > 0)
      *--dst = *--src;
  }
  return vdst;
}
 796:	6422                	ld	s0,8(sp)
 798:	0141                	addi	sp,sp,16
 79a:	8082                	ret
    dst += n;
 79c:	00c50733          	add	a4,a0,a2
    src += n;
 7a0:	95b2                	add	a1,a1,a2
    while(n-- > 0)
 7a2:	fec05ae3          	blez	a2,796 <memmove+0x28>
 7a6:	fff6079b          	addiw	a5,a2,-1
 7aa:	1782                	slli	a5,a5,0x20
 7ac:	9381                	srli	a5,a5,0x20
 7ae:	fff7c793          	not	a5,a5
 7b2:	97ba                	add	a5,a5,a4
      *--dst = *--src;
 7b4:	15fd                	addi	a1,a1,-1
 7b6:	177d                	addi	a4,a4,-1
 7b8:	0005c683          	lbu	a3,0(a1)
 7bc:	00d70023          	sb	a3,0(a4)
    while(n-- > 0)
 7c0:	fee79ae3          	bne	a5,a4,7b4 <memmove+0x46>
 7c4:	bfc9                	j	796 <memmove+0x28>

00000000000007c6 <memcmp>:

int
memcmp(const void *s1, const void *s2, uint n)
{
 7c6:	1141                	addi	sp,sp,-16
 7c8:	e422                	sd	s0,8(sp)
 7ca:	0800                	addi	s0,sp,16
  const char *p1 = s1, *p2 = s2;
  while (n-- > 0) {
 7cc:	ca05                	beqz	a2,7fc <memcmp+0x36>
 7ce:	fff6069b          	addiw	a3,a2,-1
 7d2:	1682                	slli	a3,a3,0x20
 7d4:	9281                	srli	a3,a3,0x20
 7d6:	0685                	addi	a3,a3,1
 7d8:	96aa                	add	a3,a3,a0
    if (*p1 != *p2) {
 7da:	00054783          	lbu	a5,0(a0)
 7de:	0005c703          	lbu	a4,0(a1)
 7e2:	00e79863          	bne	a5,a4,7f2 <memcmp+0x2c>
      return *p1 - *p2;
    }
    p1++;
 7e6:	0505                	addi	a0,a0,1
    p2++;
 7e8:	0585                	addi	a1,a1,1
  while (n-- > 0) {
 7ea:	fed518e3          	bne	a0,a3,7da <memcmp+0x14>
  }
  return 0;
 7ee:	4501                	li	a0,0
 7f0:	a019                	j	7f6 <memcmp+0x30>
      return *p1 - *p2;
 7f2:	40e7853b          	subw	a0,a5,a4
}
 7f6:	6422                	ld	s0,8(sp)
 7f8:	0141                	addi	sp,sp,16
 7fa:	8082                	ret
  return 0;
 7fc:	4501                	li	a0,0
 7fe:	bfe5                	j	7f6 <memcmp+0x30>

0000000000000800 <memcpy>:

void *
memcpy(void *dst, const void *src, uint n)
{
 800:	1141                	addi	sp,sp,-16
 802:	e406                	sd	ra,8(sp)
 804:	e022                	sd	s0,0(sp)
 806:	0800                	addi	s0,sp,16
  return memmove(dst, src, n);
 808:	00000097          	auipc	ra,0x0
 80c:	f66080e7          	jalr	-154(ra) # 76e <memmove>
}
 810:	60a2                	ld	ra,8(sp)
 812:	6402                	ld	s0,0(sp)
 814:	0141                	addi	sp,sp,16
 816:	8082                	ret

0000000000000818 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
 li a7, SYS_fork
 818:	4885                	li	a7,1
 ecall
 81a:	00000073          	ecall
 ret
 81e:	8082                	ret

0000000000000820 <exit>:
.global exit
exit:
 li a7, SYS_exit
 820:	4889                	li	a7,2
 ecall
 822:	00000073          	ecall
 ret
 826:	8082                	ret

0000000000000828 <wait>:
.global wait
wait:
 li a7, SYS_wait
 828:	488d                	li	a7,3
 ecall
 82a:	00000073          	ecall
 ret
 82e:	8082                	ret

0000000000000830 <pipe>:
.global pipe
pipe:
 li a7, SYS_pipe
 830:	4891                	li	a7,4
 ecall
 832:	00000073          	ecall
 ret
 836:	8082                	ret

0000000000000838 <read>:
.global read
read:
 li a7, SYS_read
 838:	4895                	li	a7,5
 ecall
 83a:	00000073          	ecall
 ret
 83e:	8082                	ret

0000000000000840 <write>:
.global write
write:
 li a7, SYS_write
 840:	48c1                	li	a7,16
 ecall
 842:	00000073          	ecall
 ret
 846:	8082                	ret

0000000000000848 <close>:
.global close
close:
 li a7, SYS_close
 848:	48d5                	li	a7,21
 ecall
 84a:	00000073          	ecall
 ret
 84e:	8082                	ret

0000000000000850 <kill>:
.global kill
kill:
 li a7, SYS_kill
 850:	4899                	li	a7,6
 ecall
 852:	00000073          	ecall
 ret
 856:	8082                	ret

0000000000000858 <exec>:
.global exec
exec:
 li a7, SYS_exec
 858:	489d                	li	a7,7
 ecall
 85a:	00000073          	ecall
 ret
 85e:	8082                	ret

0000000000000860 <open>:
.global open
open:
 li a7, SYS_open
 860:	48bd                	li	a7,15
 ecall
 862:	00000073          	ecall
 ret
 866:	8082                	ret

0000000000000868 <mknod>:
.global mknod
mknod:
 li a7, SYS_mknod
 868:	48c5                	li	a7,17
 ecall
 86a:	00000073          	ecall
 ret
 86e:	8082                	ret

0000000000000870 <unlink>:
.global unlink
unlink:
 li a7, SYS_unlink
 870:	48c9                	li	a7,18
 ecall
 872:	00000073          	ecall
 ret
 876:	8082                	ret

0000000000000878 <fstat>:
.global fstat
fstat:
 li a7, SYS_fstat
 878:	48a1                	li	a7,8
 ecall
 87a:	00000073          	ecall
 ret
 87e:	8082                	ret

0000000000000880 <link>:
.global link
link:
 li a7, SYS_link
 880:	48cd                	li	a7,19
 ecall
 882:	00000073          	ecall
 ret
 886:	8082                	ret

0000000000000888 <mkdir>:
.global mkdir
mkdir:
 li a7, SYS_mkdir
 888:	48d1                	li	a7,20
 ecall
 88a:	00000073          	ecall
 ret
 88e:	8082                	ret

0000000000000890 <chdir>:
.global chdir
chdir:
 li a7, SYS_chdir
 890:	48a5                	li	a7,9
 ecall
 892:	00000073          	ecall
 ret
 896:	8082                	ret

0000000000000898 <dup>:
.global dup
dup:
 li a7, SYS_dup
 898:	48a9                	li	a7,10
 ecall
 89a:	00000073          	ecall
 ret
 89e:	8082                	ret

00000000000008a0 <getpid>:
.global getpid
getpid:
 li a7, SYS_getpid
 8a0:	48ad                	li	a7,11
 ecall
 8a2:	00000073          	ecall
 ret
 8a6:	8082                	ret

00000000000008a8 <sbrk>:
.global sbrk
sbrk:
 li a7, SYS_sbrk
 8a8:	48b1                	li	a7,12
 ecall
 8aa:	00000073          	ecall
 ret
 8ae:	8082                	ret

00000000000008b0 <sleep>:
.global sleep
sleep:
 li a7, SYS_sleep
 8b0:	48b5                	li	a7,13
 ecall
 8b2:	00000073          	ecall
 ret
 8b6:	8082                	ret

00000000000008b8 <uptime>:
.global uptime
uptime:
 li a7, SYS_uptime
 8b8:	48b9                	li	a7,14
 ecall
 8ba:	00000073          	ecall
 ret
 8be:	8082                	ret

00000000000008c0 <rbtn>:
.global rbtn
rbtn:
 li a7, SYS_rbtn
 8c0:	48d9                	li	a7,22
 ecall
 8c2:	00000073          	ecall
 ret
 8c6:	8082                	ret

00000000000008c8 <symlink>:
.global symlink
symlink:
 li a7, SYS_symlink
 8c8:	48dd                	li	a7,23
 ecall
 8ca:	00000073          	ecall
 ret
 8ce:	8082                	ret

00000000000008d0 <putc>:

static char digits[] = "0123456789ABCDEF";

static void
putc(int fd, char c)
{
 8d0:	1101                	addi	sp,sp,-32
 8d2:	ec06                	sd	ra,24(sp)
 8d4:	e822                	sd	s0,16(sp)
 8d6:	1000                	addi	s0,sp,32
 8d8:	feb407a3          	sb	a1,-17(s0)
  write(fd, &c, 1);
 8dc:	4605                	li	a2,1
 8de:	fef40593          	addi	a1,s0,-17
 8e2:	00000097          	auipc	ra,0x0
 8e6:	f5e080e7          	jalr	-162(ra) # 840 <write>
}
 8ea:	60e2                	ld	ra,24(sp)
 8ec:	6442                	ld	s0,16(sp)
 8ee:	6105                	addi	sp,sp,32
 8f0:	8082                	ret

00000000000008f2 <printint>:

static void
printint(int fd, int xx, int base, int sgn)
{
 8f2:	7139                	addi	sp,sp,-64
 8f4:	fc06                	sd	ra,56(sp)
 8f6:	f822                	sd	s0,48(sp)
 8f8:	f426                	sd	s1,40(sp)
 8fa:	f04a                	sd	s2,32(sp)
 8fc:	ec4e                	sd	s3,24(sp)
 8fe:	0080                	addi	s0,sp,64
 900:	84aa                	mv	s1,a0
  char buf[16];
  int i, neg;
  uint x;

  neg = 0;
  if(sgn && xx < 0){
 902:	c299                	beqz	a3,908 <printint+0x16>
 904:	0805c963          	bltz	a1,996 <printint+0xa4>
    neg = 1;
    x = -xx;
  } else {
    x = xx;
 908:	2581                	sext.w	a1,a1
  neg = 0;
 90a:	4881                	li	a7,0
 90c:	fc040693          	addi	a3,s0,-64
  }

  i = 0;
 910:	4701                	li	a4,0
  do{
    buf[i++] = digits[x % base];
 912:	2601                	sext.w	a2,a2
 914:	00000517          	auipc	a0,0x0
 918:	69c50513          	addi	a0,a0,1692 # fb0 <digits>
 91c:	883a                	mv	a6,a4
 91e:	2705                	addiw	a4,a4,1
 920:	02c5f7bb          	remuw	a5,a1,a2
 924:	1782                	slli	a5,a5,0x20
 926:	9381                	srli	a5,a5,0x20
 928:	97aa                	add	a5,a5,a0
 92a:	0007c783          	lbu	a5,0(a5)
 92e:	00f68023          	sb	a5,0(a3)
  }while((x /= base) != 0);
 932:	0005879b          	sext.w	a5,a1
 936:	02c5d5bb          	divuw	a1,a1,a2
 93a:	0685                	addi	a3,a3,1
 93c:	fec7f0e3          	bgeu	a5,a2,91c <printint+0x2a>
  if(neg)
 940:	00088c63          	beqz	a7,958 <printint+0x66>
    buf[i++] = '-';
 944:	fd070793          	addi	a5,a4,-48
 948:	00878733          	add	a4,a5,s0
 94c:	02d00793          	li	a5,45
 950:	fef70823          	sb	a5,-16(a4)
 954:	0028071b          	addiw	a4,a6,2

  while(--i >= 0)
 958:	02e05863          	blez	a4,988 <printint+0x96>
 95c:	fc040793          	addi	a5,s0,-64
 960:	00e78933          	add	s2,a5,a4
 964:	fff78993          	addi	s3,a5,-1
 968:	99ba                	add	s3,s3,a4
 96a:	377d                	addiw	a4,a4,-1
 96c:	1702                	slli	a4,a4,0x20
 96e:	9301                	srli	a4,a4,0x20
 970:	40e989b3          	sub	s3,s3,a4
    putc(fd, buf[i]);
 974:	fff94583          	lbu	a1,-1(s2)
 978:	8526                	mv	a0,s1
 97a:	00000097          	auipc	ra,0x0
 97e:	f56080e7          	jalr	-170(ra) # 8d0 <putc>
  while(--i >= 0)
 982:	197d                	addi	s2,s2,-1
 984:	ff3918e3          	bne	s2,s3,974 <printint+0x82>
}
 988:	70e2                	ld	ra,56(sp)
 98a:	7442                	ld	s0,48(sp)
 98c:	74a2                	ld	s1,40(sp)
 98e:	7902                	ld	s2,32(sp)
 990:	69e2                	ld	s3,24(sp)
 992:	6121                	addi	sp,sp,64
 994:	8082                	ret
    x = -xx;
 996:	40b005bb          	negw	a1,a1
    neg = 1;
 99a:	4885                	li	a7,1
    x = -xx;
 99c:	bf85                	j	90c <printint+0x1a>

000000000000099e <vprintf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
 99e:	7119                	addi	sp,sp,-128
 9a0:	fc86                	sd	ra,120(sp)
 9a2:	f8a2                	sd	s0,112(sp)
 9a4:	f4a6                	sd	s1,104(sp)
 9a6:	f0ca                	sd	s2,96(sp)
 9a8:	ecce                	sd	s3,88(sp)
 9aa:	e8d2                	sd	s4,80(sp)
 9ac:	e4d6                	sd	s5,72(sp)
 9ae:	e0da                	sd	s6,64(sp)
 9b0:	fc5e                	sd	s7,56(sp)
 9b2:	f862                	sd	s8,48(sp)
 9b4:	f466                	sd	s9,40(sp)
 9b6:	f06a                	sd	s10,32(sp)
 9b8:	ec6e                	sd	s11,24(sp)
 9ba:	0100                	addi	s0,sp,128
  char *s;
  int c, i, state;

  state = 0;
  for(i = 0; fmt[i]; i++){
 9bc:	0005c903          	lbu	s2,0(a1)
 9c0:	18090f63          	beqz	s2,b5e <vprintf+0x1c0>
 9c4:	8aaa                	mv	s5,a0
 9c6:	8b32                	mv	s6,a2
 9c8:	00158493          	addi	s1,a1,1
  state = 0;
 9cc:	4981                	li	s3,0
      if(c == '%'){
        state = '%';
      } else {
        putc(fd, c);
      }
    } else if(state == '%'){
 9ce:	02500a13          	li	s4,37
 9d2:	4c55                	li	s8,21
 9d4:	00000c97          	auipc	s9,0x0
 9d8:	584c8c93          	addi	s9,s9,1412 # f58 <malloc+0x2f6>
        printptr(fd, va_arg(ap, uint64));
      } else if(c == 's'){
        s = va_arg(ap, char*);
        if(s == 0)
          s = "(null)";
        while(*s != 0){
 9dc:	02800d93          	li	s11,40
  putc(fd, 'x');
 9e0:	4d41                	li	s10,16
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 9e2:	00000b97          	auipc	s7,0x0
 9e6:	5ceb8b93          	addi	s7,s7,1486 # fb0 <digits>
 9ea:	a839                	j	a08 <vprintf+0x6a>
        putc(fd, c);
 9ec:	85ca                	mv	a1,s2
 9ee:	8556                	mv	a0,s5
 9f0:	00000097          	auipc	ra,0x0
 9f4:	ee0080e7          	jalr	-288(ra) # 8d0 <putc>
 9f8:	a019                	j	9fe <vprintf+0x60>
    } else if(state == '%'){
 9fa:	01498d63          	beq	s3,s4,a14 <vprintf+0x76>
  for(i = 0; fmt[i]; i++){
 9fe:	0485                	addi	s1,s1,1
 a00:	fff4c903          	lbu	s2,-1(s1)
 a04:	14090d63          	beqz	s2,b5e <vprintf+0x1c0>
    if(state == 0){
 a08:	fe0999e3          	bnez	s3,9fa <vprintf+0x5c>
      if(c == '%'){
 a0c:	ff4910e3          	bne	s2,s4,9ec <vprintf+0x4e>
        state = '%';
 a10:	89d2                	mv	s3,s4
 a12:	b7f5                	j	9fe <vprintf+0x60>
      if(c == 'd'){
 a14:	11490c63          	beq	s2,s4,b2c <vprintf+0x18e>
 a18:	f9d9079b          	addiw	a5,s2,-99
 a1c:	0ff7f793          	zext.b	a5,a5
 a20:	10fc6e63          	bltu	s8,a5,b3c <vprintf+0x19e>
 a24:	f9d9079b          	addiw	a5,s2,-99
 a28:	0ff7f713          	zext.b	a4,a5
 a2c:	10ec6863          	bltu	s8,a4,b3c <vprintf+0x19e>
 a30:	00271793          	slli	a5,a4,0x2
 a34:	97e6                	add	a5,a5,s9
 a36:	439c                	lw	a5,0(a5)
 a38:	97e6                	add	a5,a5,s9
 a3a:	8782                	jr	a5
        printint(fd, va_arg(ap, int), 10, 1);
 a3c:	008b0913          	addi	s2,s6,8
 a40:	4685                	li	a3,1
 a42:	4629                	li	a2,10
 a44:	000b2583          	lw	a1,0(s6)
 a48:	8556                	mv	a0,s5
 a4a:	00000097          	auipc	ra,0x0
 a4e:	ea8080e7          	jalr	-344(ra) # 8f2 <printint>
 a52:	8b4a                	mv	s6,s2
      } else {
        // Unknown % sequence.  Print it to draw attention.
        putc(fd, '%');
        putc(fd, c);
      }
      state = 0;
 a54:	4981                	li	s3,0
 a56:	b765                	j	9fe <vprintf+0x60>
        printint(fd, va_arg(ap, uint64), 10, 0);
 a58:	008b0913          	addi	s2,s6,8
 a5c:	4681                	li	a3,0
 a5e:	4629                	li	a2,10
 a60:	000b2583          	lw	a1,0(s6)
 a64:	8556                	mv	a0,s5
 a66:	00000097          	auipc	ra,0x0
 a6a:	e8c080e7          	jalr	-372(ra) # 8f2 <printint>
 a6e:	8b4a                	mv	s6,s2
      state = 0;
 a70:	4981                	li	s3,0
 a72:	b771                	j	9fe <vprintf+0x60>
        printint(fd, va_arg(ap, int), 16, 0);
 a74:	008b0913          	addi	s2,s6,8
 a78:	4681                	li	a3,0
 a7a:	866a                	mv	a2,s10
 a7c:	000b2583          	lw	a1,0(s6)
 a80:	8556                	mv	a0,s5
 a82:	00000097          	auipc	ra,0x0
 a86:	e70080e7          	jalr	-400(ra) # 8f2 <printint>
 a8a:	8b4a                	mv	s6,s2
      state = 0;
 a8c:	4981                	li	s3,0
 a8e:	bf85                	j	9fe <vprintf+0x60>
        printptr(fd, va_arg(ap, uint64));
 a90:	008b0793          	addi	a5,s6,8
 a94:	f8f43423          	sd	a5,-120(s0)
 a98:	000b3983          	ld	s3,0(s6)
  putc(fd, '0');
 a9c:	03000593          	li	a1,48
 aa0:	8556                	mv	a0,s5
 aa2:	00000097          	auipc	ra,0x0
 aa6:	e2e080e7          	jalr	-466(ra) # 8d0 <putc>
  putc(fd, 'x');
 aaa:	07800593          	li	a1,120
 aae:	8556                	mv	a0,s5
 ab0:	00000097          	auipc	ra,0x0
 ab4:	e20080e7          	jalr	-480(ra) # 8d0 <putc>
 ab8:	896a                	mv	s2,s10
    putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
 aba:	03c9d793          	srli	a5,s3,0x3c
 abe:	97de                	add	a5,a5,s7
 ac0:	0007c583          	lbu	a1,0(a5)
 ac4:	8556                	mv	a0,s5
 ac6:	00000097          	auipc	ra,0x0
 aca:	e0a080e7          	jalr	-502(ra) # 8d0 <putc>
  for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
 ace:	0992                	slli	s3,s3,0x4
 ad0:	397d                	addiw	s2,s2,-1
 ad2:	fe0914e3          	bnez	s2,aba <vprintf+0x11c>
        printptr(fd, va_arg(ap, uint64));
 ad6:	f8843b03          	ld	s6,-120(s0)
      state = 0;
 ada:	4981                	li	s3,0
 adc:	b70d                	j	9fe <vprintf+0x60>
        s = va_arg(ap, char*);
 ade:	008b0913          	addi	s2,s6,8
 ae2:	000b3983          	ld	s3,0(s6)
        if(s == 0)
 ae6:	02098163          	beqz	s3,b08 <vprintf+0x16a>
        while(*s != 0){
 aea:	0009c583          	lbu	a1,0(s3)
 aee:	c5ad                	beqz	a1,b58 <vprintf+0x1ba>
          putc(fd, *s);
 af0:	8556                	mv	a0,s5
 af2:	00000097          	auipc	ra,0x0
 af6:	dde080e7          	jalr	-546(ra) # 8d0 <putc>
          s++;
 afa:	0985                	addi	s3,s3,1
        while(*s != 0){
 afc:	0009c583          	lbu	a1,0(s3)
 b00:	f9e5                	bnez	a1,af0 <vprintf+0x152>
        s = va_arg(ap, char*);
 b02:	8b4a                	mv	s6,s2
      state = 0;
 b04:	4981                	li	s3,0
 b06:	bde5                	j	9fe <vprintf+0x60>
          s = "(null)";
 b08:	00000997          	auipc	s3,0x0
 b0c:	44898993          	addi	s3,s3,1096 # f50 <malloc+0x2ee>
        while(*s != 0){
 b10:	85ee                	mv	a1,s11
 b12:	bff9                	j	af0 <vprintf+0x152>
        putc(fd, va_arg(ap, uint));
 b14:	008b0913          	addi	s2,s6,8
 b18:	000b4583          	lbu	a1,0(s6)
 b1c:	8556                	mv	a0,s5
 b1e:	00000097          	auipc	ra,0x0
 b22:	db2080e7          	jalr	-590(ra) # 8d0 <putc>
 b26:	8b4a                	mv	s6,s2
      state = 0;
 b28:	4981                	li	s3,0
 b2a:	bdd1                	j	9fe <vprintf+0x60>
        putc(fd, c);
 b2c:	85d2                	mv	a1,s4
 b2e:	8556                	mv	a0,s5
 b30:	00000097          	auipc	ra,0x0
 b34:	da0080e7          	jalr	-608(ra) # 8d0 <putc>
      state = 0;
 b38:	4981                	li	s3,0
 b3a:	b5d1                	j	9fe <vprintf+0x60>
        putc(fd, '%');
 b3c:	85d2                	mv	a1,s4
 b3e:	8556                	mv	a0,s5
 b40:	00000097          	auipc	ra,0x0
 b44:	d90080e7          	jalr	-624(ra) # 8d0 <putc>
        putc(fd, c);
 b48:	85ca                	mv	a1,s2
 b4a:	8556                	mv	a0,s5
 b4c:	00000097          	auipc	ra,0x0
 b50:	d84080e7          	jalr	-636(ra) # 8d0 <putc>
      state = 0;
 b54:	4981                	li	s3,0
 b56:	b565                	j	9fe <vprintf+0x60>
        s = va_arg(ap, char*);
 b58:	8b4a                	mv	s6,s2
      state = 0;
 b5a:	4981                	li	s3,0
 b5c:	b54d                	j	9fe <vprintf+0x60>
    }
  }
}
 b5e:	70e6                	ld	ra,120(sp)
 b60:	7446                	ld	s0,112(sp)
 b62:	74a6                	ld	s1,104(sp)
 b64:	7906                	ld	s2,96(sp)
 b66:	69e6                	ld	s3,88(sp)
 b68:	6a46                	ld	s4,80(sp)
 b6a:	6aa6                	ld	s5,72(sp)
 b6c:	6b06                	ld	s6,64(sp)
 b6e:	7be2                	ld	s7,56(sp)
 b70:	7c42                	ld	s8,48(sp)
 b72:	7ca2                	ld	s9,40(sp)
 b74:	7d02                	ld	s10,32(sp)
 b76:	6de2                	ld	s11,24(sp)
 b78:	6109                	addi	sp,sp,128
 b7a:	8082                	ret

0000000000000b7c <fprintf>:

void
fprintf(int fd, const char *fmt, ...)
{
 b7c:	715d                	addi	sp,sp,-80
 b7e:	ec06                	sd	ra,24(sp)
 b80:	e822                	sd	s0,16(sp)
 b82:	1000                	addi	s0,sp,32
 b84:	e010                	sd	a2,0(s0)
 b86:	e414                	sd	a3,8(s0)
 b88:	e818                	sd	a4,16(s0)
 b8a:	ec1c                	sd	a5,24(s0)
 b8c:	03043023          	sd	a6,32(s0)
 b90:	03143423          	sd	a7,40(s0)
  va_list ap;

  va_start(ap, fmt);
 b94:	fe843423          	sd	s0,-24(s0)
  vprintf(fd, fmt, ap);
 b98:	8622                	mv	a2,s0
 b9a:	00000097          	auipc	ra,0x0
 b9e:	e04080e7          	jalr	-508(ra) # 99e <vprintf>
}
 ba2:	60e2                	ld	ra,24(sp)
 ba4:	6442                	ld	s0,16(sp)
 ba6:	6161                	addi	sp,sp,80
 ba8:	8082                	ret

0000000000000baa <printf>:

void
printf(const char *fmt, ...)
{
 baa:	711d                	addi	sp,sp,-96
 bac:	ec06                	sd	ra,24(sp)
 bae:	e822                	sd	s0,16(sp)
 bb0:	1000                	addi	s0,sp,32
 bb2:	e40c                	sd	a1,8(s0)
 bb4:	e810                	sd	a2,16(s0)
 bb6:	ec14                	sd	a3,24(s0)
 bb8:	f018                	sd	a4,32(s0)
 bba:	f41c                	sd	a5,40(s0)
 bbc:	03043823          	sd	a6,48(s0)
 bc0:	03143c23          	sd	a7,56(s0)
  va_list ap;

  va_start(ap, fmt);
 bc4:	00840613          	addi	a2,s0,8
 bc8:	fec43423          	sd	a2,-24(s0)
  vprintf(1, fmt, ap);
 bcc:	85aa                	mv	a1,a0
 bce:	4505                	li	a0,1
 bd0:	00000097          	auipc	ra,0x0
 bd4:	dce080e7          	jalr	-562(ra) # 99e <vprintf>
}
 bd8:	60e2                	ld	ra,24(sp)
 bda:	6442                	ld	s0,16(sp)
 bdc:	6125                	addi	sp,sp,96
 bde:	8082                	ret

0000000000000be0 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
 be0:	1141                	addi	sp,sp,-16
 be2:	e422                	sd	s0,8(sp)
 be4:	0800                	addi	s0,sp,16
  Header *bp, *p;

  bp = (Header*)ap - 1;
 be6:	ff050693          	addi	a3,a0,-16
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 bea:	00000797          	auipc	a5,0x0
 bee:	3de7b783          	ld	a5,990(a5) # fc8 <freep>
 bf2:	a02d                	j	c1c <free+0x3c>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
 bf4:	4618                	lw	a4,8(a2)
 bf6:	9f2d                	addw	a4,a4,a1
 bf8:	fee52c23          	sw	a4,-8(a0)
    bp->s.ptr = p->s.ptr->s.ptr;
 bfc:	6398                	ld	a4,0(a5)
 bfe:	6310                	ld	a2,0(a4)
 c00:	a83d                	j	c3e <free+0x5e>
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
    p->s.size += bp->s.size;
 c02:	ff852703          	lw	a4,-8(a0)
 c06:	9f31                	addw	a4,a4,a2
 c08:	c798                	sw	a4,8(a5)
    p->s.ptr = bp->s.ptr;
 c0a:	ff053683          	ld	a3,-16(a0)
 c0e:	a091                	j	c52 <free+0x72>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 c10:	6398                	ld	a4,0(a5)
 c12:	00e7e463          	bltu	a5,a4,c1a <free+0x3a>
 c16:	00e6ea63          	bltu	a3,a4,c2a <free+0x4a>
{
 c1a:	87ba                	mv	a5,a4
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
 c1c:	fed7fae3          	bgeu	a5,a3,c10 <free+0x30>
 c20:	6398                	ld	a4,0(a5)
 c22:	00e6e463          	bltu	a3,a4,c2a <free+0x4a>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
 c26:	fee7eae3          	bltu	a5,a4,c1a <free+0x3a>
  if(bp + bp->s.size == p->s.ptr){
 c2a:	ff852583          	lw	a1,-8(a0)
 c2e:	6390                	ld	a2,0(a5)
 c30:	02059813          	slli	a6,a1,0x20
 c34:	01c85713          	srli	a4,a6,0x1c
 c38:	9736                	add	a4,a4,a3
 c3a:	fae60de3          	beq	a2,a4,bf4 <free+0x14>
    bp->s.ptr = p->s.ptr->s.ptr;
 c3e:	fec53823          	sd	a2,-16(a0)
  if(p + p->s.size == bp){
 c42:	4790                	lw	a2,8(a5)
 c44:	02061593          	slli	a1,a2,0x20
 c48:	01c5d713          	srli	a4,a1,0x1c
 c4c:	973e                	add	a4,a4,a5
 c4e:	fae68ae3          	beq	a3,a4,c02 <free+0x22>
    p->s.ptr = bp->s.ptr;
 c52:	e394                	sd	a3,0(a5)
  } else
    p->s.ptr = bp;
  freep = p;
 c54:	00000717          	auipc	a4,0x0
 c58:	36f73a23          	sd	a5,884(a4) # fc8 <freep>
}
 c5c:	6422                	ld	s0,8(sp)
 c5e:	0141                	addi	sp,sp,16
 c60:	8082                	ret

0000000000000c62 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
 c62:	7139                	addi	sp,sp,-64
 c64:	fc06                	sd	ra,56(sp)
 c66:	f822                	sd	s0,48(sp)
 c68:	f426                	sd	s1,40(sp)
 c6a:	f04a                	sd	s2,32(sp)
 c6c:	ec4e                	sd	s3,24(sp)
 c6e:	e852                	sd	s4,16(sp)
 c70:	e456                	sd	s5,8(sp)
 c72:	e05a                	sd	s6,0(sp)
 c74:	0080                	addi	s0,sp,64
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
 c76:	02051493          	slli	s1,a0,0x20
 c7a:	9081                	srli	s1,s1,0x20
 c7c:	04bd                	addi	s1,s1,15
 c7e:	8091                	srli	s1,s1,0x4
 c80:	0014899b          	addiw	s3,s1,1
 c84:	0485                	addi	s1,s1,1
  if((prevp = freep) == 0){
 c86:	00000517          	auipc	a0,0x0
 c8a:	34253503          	ld	a0,834(a0) # fc8 <freep>
 c8e:	c515                	beqz	a0,cba <malloc+0x58>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 c90:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 c92:	4798                	lw	a4,8(a5)
 c94:	02977f63          	bgeu	a4,s1,cd2 <malloc+0x70>
 c98:	8a4e                	mv	s4,s3
 c9a:	0009871b          	sext.w	a4,s3
 c9e:	6685                	lui	a3,0x1
 ca0:	00d77363          	bgeu	a4,a3,ca6 <malloc+0x44>
 ca4:	6a05                	lui	s4,0x1
 ca6:	000a0b1b          	sext.w	s6,s4
  p = sbrk(nu * sizeof(Header));
 caa:	004a1a1b          	slliw	s4,s4,0x4
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*)(p + 1);
    }
    if(p == freep)
 cae:	00000917          	auipc	s2,0x0
 cb2:	31a90913          	addi	s2,s2,794 # fc8 <freep>
  if(p == (char*)-1)
 cb6:	5afd                	li	s5,-1
 cb8:	a895                	j	d2c <malloc+0xca>
    base.s.ptr = freep = prevp = &base;
 cba:	00000797          	auipc	a5,0x0
 cbe:	31678793          	addi	a5,a5,790 # fd0 <base>
 cc2:	00000717          	auipc	a4,0x0
 cc6:	30f73323          	sd	a5,774(a4) # fc8 <freep>
 cca:	e39c                	sd	a5,0(a5)
    base.s.size = 0;
 ccc:	0007a423          	sw	zero,8(a5)
    if(p->s.size >= nunits){
 cd0:	b7e1                	j	c98 <malloc+0x36>
      if(p->s.size == nunits)
 cd2:	02e48c63          	beq	s1,a4,d0a <malloc+0xa8>
        p->s.size -= nunits;
 cd6:	4137073b          	subw	a4,a4,s3
 cda:	c798                	sw	a4,8(a5)
        p += p->s.size;
 cdc:	02071693          	slli	a3,a4,0x20
 ce0:	01c6d713          	srli	a4,a3,0x1c
 ce4:	97ba                	add	a5,a5,a4
        p->s.size = nunits;
 ce6:	0137a423          	sw	s3,8(a5)
      freep = prevp;
 cea:	00000717          	auipc	a4,0x0
 cee:	2ca73f23          	sd	a0,734(a4) # fc8 <freep>
      return (void*)(p + 1);
 cf2:	01078513          	addi	a0,a5,16
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
 cf6:	70e2                	ld	ra,56(sp)
 cf8:	7442                	ld	s0,48(sp)
 cfa:	74a2                	ld	s1,40(sp)
 cfc:	7902                	ld	s2,32(sp)
 cfe:	69e2                	ld	s3,24(sp)
 d00:	6a42                	ld	s4,16(sp)
 d02:	6aa2                	ld	s5,8(sp)
 d04:	6b02                	ld	s6,0(sp)
 d06:	6121                	addi	sp,sp,64
 d08:	8082                	ret
        prevp->s.ptr = p->s.ptr;
 d0a:	6398                	ld	a4,0(a5)
 d0c:	e118                	sd	a4,0(a0)
 d0e:	bff1                	j	cea <malloc+0x88>
  hp->s.size = nu;
 d10:	01652423          	sw	s6,8(a0)
  free((void*)(hp + 1));
 d14:	0541                	addi	a0,a0,16
 d16:	00000097          	auipc	ra,0x0
 d1a:	eca080e7          	jalr	-310(ra) # be0 <free>
  return freep;
 d1e:	00093503          	ld	a0,0(s2)
      if((p = morecore(nunits)) == 0)
 d22:	d971                	beqz	a0,cf6 <malloc+0x94>
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
 d24:	611c                	ld	a5,0(a0)
    if(p->s.size >= nunits){
 d26:	4798                	lw	a4,8(a5)
 d28:	fa9775e3          	bgeu	a4,s1,cd2 <malloc+0x70>
    if(p == freep)
 d2c:	00093703          	ld	a4,0(s2)
 d30:	853e                	mv	a0,a5
 d32:	fef719e3          	bne	a4,a5,d24 <malloc+0xc2>
  p = sbrk(nu * sizeof(Header));
 d36:	8552                	mv	a0,s4
 d38:	00000097          	auipc	ra,0x0
 d3c:	b70080e7          	jalr	-1168(ra) # 8a8 <sbrk>
  if(p == (char*)-1)
 d40:	fd5518e3          	bne	a0,s5,d10 <malloc+0xae>
        return 0;
 d44:	4501                	li	a0,0
 d46:	bf45                	j	cf6 <malloc+0x94>
